package com.yanfan.energybilling.tdengine;

import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.yanfan.energybilling.domain.TDEnergyDeductionRecord;
import com.yanfan.energybilling.domain.dto.TDEnergyDeductionRecordDto;
import com.yanfan.energybilling.domain.vo.EnergyCostStatisticsVo;
import com.yanfan.energybilling.domain.vo.EnergyStatisticsVo;
import com.yanfan.energybilling.domain.vo.GroupByEnergyTypeVo;
import com.yanfan.energybilling.domain.vo.StaticRequestParamVo;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;

public interface TDEnergyDeductionRecordMapper {
    /***
     * 创建超级表
     */
    //忽略多租户注解
    @InterceptorIgnore(tenantLine = "true")
    int createTable(String database);

    /***
     * 新增数据
     */
    int save(@Param("database") String database, @Param("data") TDEnergyDeductionRecord log);
    int saveBatch(@Param("database") String database, @Param("records") TDEnergyDeductionRecordDto records);

    int tableExit(@Param("database") String database);
    Long selectTimeRangeLast(@Param("database") String database,@Param("begin")Long begin,@Param("end")Long end);

    TDEnergyDeductionRecord selectLatestRecord(@Param("database") String database, @Param("serialNumber") String serialNumber, @Param("thingsModelId") String thingsModelId);

    List<EnergyStatisticsVo> buildingEnergyStatistics(String dbName);

    List<EnergyCostStatisticsVo> energyCostStatisticsTimeWindow(@Param("database") String database, @Param("param") StaticRequestParamVo param);

    List<EnergyCostStatisticsVo> energyCostStatisticsTimeWindowData(@Param("database") String database, @Param("param") StaticRequestParamVo param);

    List<EnergyCostStatisticsVo> energyConsumeStatisticsTimeWindow(@Param("database") String database, @Param("param") StaticRequestParamVo param);

    List<EnergyCostStatisticsVo> energyCountAllStatisticsTimeWindow(@Param("database") String database, @Param("param") StaticRequestParamVo param);

    BigDecimal energyCost(@Param("database") String database, @Param("param") StaticRequestParamVo param);

    List<GroupByEnergyTypeVo> totalDifferenceValueGroupByEnergyType(@Param("database") String database,@Param("beginTime") String beginTime ,@Param("endTime") String endTime);

    List<GroupByEnergyTypeVo> buildEcharts(@Param("database") String dbName,@Param("timeType")String timeType,@Param("energyTypeList") List<String> energyTypeList, @Param("beginTime") String beginTime ,@Param("endTime") String endTime,@Param("deviceNumbers") List<String> deviceNumbers);

    List<GroupByEnergyTypeVo> sumDifferenceValueGroupByBuilding(@Param("database") String dbName,@Param("energyType") String energyType);
}
